home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime for java / qteffects / src / playqteffectapp.java
Encoding:
Java Source  |  2000-09-28  |  3.3 KB  |  102 lines

  1. /*
  2.  * QuickTime for Java SDK Sample Code
  3.  
  4.    Usage subject to restrictions in SDK License Agreement
  5.  * Copyright: © 1996-1999 Apple Computer, Inc.
  6.  
  7.  */
  8. import java.awt.event.*;
  9. import java.awt.*;
  10. import java.io.*;
  11.  
  12. import quicktime.std.movies.*;
  13. import quicktime.std.*;
  14. import quicktime.*;
  15. import quicktime.qd.*;
  16.  
  17. import quicktime.io.QTFile;
  18. import quicktime.app.image.GraphicsImporterDrawer;
  19. import quicktime.app.display.*;
  20. import quicktime.app.QTFactory;
  21.  
  22. import quicktime.app.image.*;
  23. import quicktime.util.*;
  24.  
  25. import qteffect.ControlPanel;
  26.  
  27. public class PlayQTEffectApp extends Frame implements QDConstants, StdQTConstants, Errors {
  28.     public static void main (String args[]) {
  29.         PlayQTEffectApp pe = new PlayQTEffectApp("QT Effects");
  30.         pe.show();
  31.         pe.toFront();
  32.     }
  33.  
  34.     PlayQTEffectApp (String name) { 
  35.         super (name);
  36.         try { 
  37.             addNotify();
  38.             Insets ins = getInsets(); 
  39.             setBounds (0, 0, (400 + ins.left + ins.right), (400 + ins.top + ins.bottom));
  40.             QTSession.open();
  41.  
  42.             File file1 = QTFactory.findAbsolutePath ("pics/house.jpg");
  43.             File file2 = QTFactory.findAbsolutePath ("pics/icons.jpg");
  44.             QTFile f1 = new QTFile (file1.getAbsolutePath());
  45.             QTFile f2 = new QTFile (file2.getAbsolutePath());
  46.             
  47.             Compositable sourceImage = new GraphicsImporterDrawer (f1);
  48.             Compositable destImage = new GraphicsImporterDrawer (f2);
  49. /*
  50. //    Example Code for creating a filter
  51.             QTFilter ef = new QTFilter ();
  52.             AtomContainer effectSample = new AtomContainer();
  53.             effectSample.insertChild (new Atom(kParentAtomIsContainer), kEffectWhatAtom, 1, 0, kEmbossImageFilterType);
  54.             ef.setSourceImage (sourceImage);
  55.             ef.setEffect (effectSample);
  56. */                
  57.  
  58. //    Example Code for creating a transition
  59.             QTTransition ef = new QTTransition ();
  60.             ef.setTime (800);
  61.             ef.setSourceImage (sourceImage);
  62.             ef.setDestinationImage (destImage);
  63.             ef.setProfiled(true);
  64.             ef.setEffect (createSMPTEEffect (kEffectWipe, kRandomWipeTransitionType));
  65.         
  66.             QTCanvas qtCanvas = new QTCanvas(QTCanvas.kAspectResize, 0.5f, 0.5f);
  67.             add("Center", qtCanvas);
  68.             ControlPanel cp = new ControlPanel (ef, qtCanvas);
  69.             add ("North", cp);
  70.             
  71.             qtCanvas.setClient (ef, true);
  72.             addWindowListener(new WindowAdapter () {
  73.                 public void windowClosing (WindowEvent e) {
  74.                     QTSession.close();
  75.                     dispose();
  76.                 }
  77.                 public void windowClosed (WindowEvent e) { 
  78.                     System.exit(0);
  79.                 }
  80.             });
  81.         } catch (Exception e) {
  82.             throw new QTRuntimeException (e.getMessage());
  83.         }
  84.     }
  85.  
  86.     public static void showDialog (QTEffect ef) throws QTException {    
  87.         AtomContainer effectSample = ParameterDialog.showParameterDialog (new EffectsList (2, 2, 0), 0);
  88.         ef.setEffect (effectSample);
  89.     }
  90.     
  91.     public AtomContainer createSMPTEEffect (int effectType, int effectNumber) throws QTException {
  92.         AtomContainer effectSample = new AtomContainer();
  93.  
  94.     // We are using SMPTE Effects so set the what atom to smpt
  95.         effectSample.insertChild (new Atom(kParentAtomIsContainer), kEffectWhatAtom, 1, 0, EndianOrder.flipNativeToBigEndian32(kWipeTransitionType));
  96.         
  97.     // We are using SMPTE effect number 74    - start at 0%, stop at 100%
  98.         effectSample.insertChild (new Atom(kParentAtomIsContainer), effectType, 1, 0, EndianOrder.flipNativeToBigEndian32(effectNumber));
  99.         return effectSample;
  100.     }
  101. }
  102.